package cn.cs.service;

import cn.cs.mapper.CsPersonMapper;
import cn.cs.pojo.CsPerson;
import cn.cs.pojo.CsRoleUser;
import cn.cs.pojo.UserCompany;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
public class CsPersonService {

    @Resource
    private CsPersonMapper csPersonMapper;


    @RequestMapping(value = "/findPersonByName", method = RequestMethod.POST)
    public CsPerson findPersonByName(@RequestParam(value = "username") String username){
        return csPersonMapper.findPersonByName(username);
    }

    @RequestMapping(value = "/findPersonById", method = RequestMethod.POST)
    public CsPerson findPersonById(@RequestParam(value = "id") String id)throws Exception{
        return csPersonMapper.getCsPersonById(id);
    }


    @RequestMapping(value = "/getCsPersonById", method = RequestMethod.POST)
    public CsPerson getCsPersonById(@RequestParam(value = "id") String id) throws Exception{
        return csPersonMapper.getCsPersonById(id);
    }

    @RequestMapping(value = "/getPersonById", method = RequestMethod.POST)
    public CsPerson getPersonById(@RequestParam(value = "id") String id) throws Exception{
        return csPersonMapper.getPersonById(id);
    }

    @RequestMapping(value = "/getCsPersonListByMap", method = RequestMethod.POST)
    public List<CsPerson> getCsPersonListByMap(@RequestBody Map<String, Object> param) throws Exception{
        return csPersonMapper.getCsPersonListByMap(param);
    }

    @RequestMapping(value = "/getCsPersonCountByMap", method = RequestMethod.POST)
    public Integer getCsPersonCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return csPersonMapper.getCsPersonCountByMap(param);
    }

    @RequestMapping(value = "/addCsPerson", method = RequestMethod.POST)
    public Integer addCsPerson(@RequestBody CsPerson csPerson) throws Exception{
        return csPersonMapper.insertCsPerson(csPerson);
    }

    @RequestMapping(value = "/modifyCsPerson", method = RequestMethod.POST)
    public Integer modifyCsPerson(@RequestBody CsPerson csPerson) throws Exception{
        return csPersonMapper.updateCsPerson(csPerson);
    }

    @RequestMapping(value = "/deleteCsPersonById", method = RequestMethod.POST)
    public Integer deleteCsPersonById(@RequestParam(value = "id") String id) throws Exception{
        return csPersonMapper.deleteCsPersonById(id);
    }

    @RequestMapping(value = "/insertPerSonRoleBatch", method = RequestMethod.POST)
    public Integer insertPerSonRoleBatch(@RequestBody List<CsRoleUser> list, @RequestParam(value = "id") String id){
        return csPersonMapper.insertPerSonRoleBatch(list, id);
    }

}
